home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_13_11 / phillip2 / unfixt.c < prev    next >
C/C++ Source or Header  |  1993-06-07  |  3KB  |  101 lines

  1.  
  2.        /***********************************************
  3.        *
  4.        *   file d:\cips\fixt.c
  5.        *
  6.        *   Functions: This file contains
  7.        *      main
  8.        *
  9.        *   Purpose:
  10.        *      This file contains the main calling
  11.        *      routine to unfix thresholded images.
  12.        *      It takes an image, such as a 200 100
  13.        *      image, and makes it a 200 0 image.
  14.        *
  15.        *   External Calls:
  16.        *      gin.c - get_image_name
  17.        *      numcvrt.c - get_integer
  18.        *                  int_convert
  19.        *      tiff.c - read_tiff_header
  20.        *
  21.        *
  22.        *   Modifications:
  23.        *      24 October 1992 - created
  24.        *
  25.        *************************************************/
  26.  
  27. #include "cips.h"
  28.  
  29.  
  30.  
  31. short the_image[ROWS][COLS];
  32. short out_image[ROWS][COLS];
  33. unsigned long histogram[GRAY_LEVELS+1];
  34. long slopes[GRAY_LEVELS+1];
  35.  
  36. main(argc, argv)
  37.    int argc;
  38.    char *argv[];
  39. {
  40.  
  41.    char name[80], name2[80], response[80];
  42.  
  43.    int  a, b, count, i, ie, il, j, k, le, length, ll,
  44.         peak1, peak2, size,
  45.         t, type, v, width;
  46.    short background, hi, low, object, value;
  47.  
  48.  
  49.    struct   tiff_header_struct image_header;
  50.  
  51.    my_clear_text_screen();
  52.  
  53.    if(argc < 4){
  54.     printf("\n\nfixt in-file out-file value ");
  55.     printf("\n");
  56.     exit(0);
  57.    }
  58.  
  59.    strcpy(name, argv[1]);
  60.    strcpy(name2, argv[2]);
  61.    value = atoi(argv[3]);
  62.  
  63.    il = 1;
  64.    ie = 1;
  65.    ll = ROWS+1;
  66.    le = COLS+1;
  67.  
  68.    read_tiff_header(name, &image_header);
  69.  
  70.    length = (ROWS-10 + image_header.image_length)/ROWS;
  71.    width  = (COLS-10 +image_header.image_width)/COLS;
  72.    count  = 1;
  73.    printf("\nlength=%d  width=%d", length, width);
  74.  
  75.    create_file_if_needed(name, name2, out_image);
  76.  
  77.      for(i=0; i<length; i++){
  78.         for(j=0; j<width; j++){
  79.           printf("\nrunning %d of %d", count, length*width);
  80.           count++;
  81.              read_tiff_image(name, the_image,
  82.                   il+i*ROWS, ie+j*COLS,
  83.                   ll+i*ROWS, le+j*COLS);
  84.  
  85.                  for(a=0; a<ROWS; a++){
  86.                     for(b=0; b<COLS; b++){
  87.                         if(the_image[a][b] != value)
  88.                             the_image[a][b] = 0;
  89.                      }
  90.                  }
  91.  
  92.              write_array_into_tiff_image(name2, the_image,
  93.                               il+i*ROWS,
  94.                               ie+j*COLS,
  95.                               ll+i*ROWS,
  96.                               le+j*COLS);
  97.         }  /* ends loop over i */
  98.      }  /* ends loop over j */
  99.  
  100. }  /* ends main */
  101.